import tensorflow as tf

with tf.device("cpu"):
    a = tf.constant([1])

print(a)
print(a.device)
print(a.numpy())
print(a.ndim)
print(a.dtype)
print(tf.is_tensor(a))

b = tf.ones([2])
print(b)
print(b.numpy())

b = tf.ones([2, 3])
print(b)
print(b.numpy())

c = tf.random.normal([2, 2], mean=1, stddev=1)
print(c)
print(c.numpy())

# 随机打散
idx = tf.range(10)
print(idx)
idx = tf.random.shuffle(idx)
print(idx)
